package com.cccyy.data.str2map;

import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class Str2Map {
    public static void main(String[] args) {
        String backInfo = "{\"data\":{\"responseHead\":{\"providerSeqNo\":\"b39856c4-0ca7-4b04-9d82-a49567f8a25f\",\"status\":0},\"responseBody\":{\"approveIdeaDetails\":[{\"name\":2,\"value\":1},{\"name\":1,\"value\":1},{\"name\":3,\"value\":1}],\"finalStrategyResult\":{\"primaryCause\":\"\",\"strategyResult\":0,\"notifyRule\":\"\",\"message\":\"\",\"secondaryCause\":\"\"}}},\"message\":\"成功\",\"status\":\"0\"}";
        JSONObject jsonObject = JSONObject.parseObject(backInfo);
        Map map = new HashMap();
        //循环转换
        Iterator it = jsonObject.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<String, Object> entry = (Map.Entry<String, Object>) it.next();
            map.put(entry.getKey(), entry.getValue());
        }
        Map data = (Map) map.get("com/cccyy/data");
        Map responseBody = (Map) data.get("responseBody");
        List<Map> strategyResults = (List<Map>) responseBody.get("strategyResults");

        Map responseHead = (Map) data.get("responseHead");
        Object status = responseHead.get("status");
        String s = status.toString();

        String status1 = String.valueOf(responseHead.get("status"));


        Map finalStrategyResult = (Map) responseBody.get("finalStrategyResult");
        map.put("finalStrategyResult", finalStrategyResult);
        System.out.println("测试结束");
    }
}
